home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6747 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  42 lines

  1. Path: gabi-soft.fr!usenet
  2. From: kanze@gabi.gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Bug or Feature? const int variables do not export in gcc 2.7.0
  5. Followup-To: comp.lang.c++
  6. Date: 12 Feb 1996 10:37:52 GMT
  7. Organization: GABI Software, Sarl.
  8. Message-ID: <KANZE.96Feb12113753@gabi.gabi-soft.fr>
  9. References: <4fdlee$bpf@netlab.cs.rpi.edu>
  10. NNTP-Posting-Host: gabi.gabi-soft.fr
  11. In-reply-to: ivo.welch@AGSM.UCLA.EDU's message of 8 Feb 1996 20:11:58 -0000
  12.  
  13. In article <4fdlee$bpf@netlab.cs.rpi.edu> ivo.welch@AGSM.UCLA.EDU (Ivo
  14. Welch) writes:
  15.  
  16. > On a NextStep/FIP system w/ gcc 2.7.0:
  17. > File try2.cc:
  18. >     int ex1=2;
  19. > File try1.cc:
  20. >     extern "C" { 
  21. >     #include <stdio.h>
  22. >     }
  23. >     int main() {
  24. >       extern int ex1; printf("Extern = %d\n", ex1); return 0; }
  25. > works, but if I replace "int" with "const int" in both situations, the 
  26. > linker complains that ex1 is not defined.  NOTE that it works with "const" 
  27. > in gcc if instead of C++ I switch to plain C.
  28.  
  29. This is as it should be.  The implicit linkage for const is static (in
  30. C++, but not in C).  Just insert the keywork extern in front of the
  31. declaration.
  32.  
  33. -- 
  34. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  35. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  36. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  37.               -- A la recherche d'une activitΘ dans une region francophone
  38.